﻿Public Class DmNhomVatTu

    Protected Overrides Function ProcessCmdKey(ByRef msg As System.Windows.Forms.Message, ByVal keyData As System.Windows.Forms.Keys) As Boolean
        If keyData = (Keys.Control Or Keys.N) Then
            Return Me.Dmnhomvattu_IUltraGrid.getTaoMoi()
        End If
        If keyData = (Keys.Control Or Keys.S) Then
            Me.Dmnhomvattu_IUltraGrid.getLuu()
            Return True
        End If
        If keyData = (Keys.Control Or Keys.D) Then
            Return Me.Dmnhomvattu_IUltraGrid.getXoa()
        End If
        If keyData = (Keys.Control Or Keys.R) Then
            Return Me.Dmnhomvattu_IUltraGrid.getRefresh()
        End If
        If keyData = (Keys.Control Or Keys.P) Then
            Return getIn()
        End If
        If keyData = (Keys.Control Or Keys.Q) Then
          Return getThoat()
        End If
        Return MyBase.ProcessCmdKey(msg, keyData)
    End Function


    Private Sub DmNhomVatTu_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        Me.Cursor = Cursors.WaitCursor
        'TODO: This line of code loads data into the 'ErpharmaDataSet.dmnhomvattu' table. You can move, or remove it, as needed.
        Me.DmnhomvattuTableAdapter.Fill(Me.ErpharmaDataSet.dmnhomvattu)
        Me.DmtinhtrangTableAdapter.Fill(Me.ErpharmaDataSet.dmtinhtrang)
      
        Me.Dmnhomvattu_IUltraGrid.setDoiTuongXuLyDuLieu(Me.ErpharmaDataSet.dmnhomvattu, Me.DmnhomvattuBindingSource, Me.DmnhomvattuTableAdapter, Me.ErpharmaDataSet)
        Me.Dmnhomvattu_IUltraGrid.setGiaoDienVua()
        Me.Dmnhomvattu_IUltraGrid.setTimKiemTrenCotUltraGrid()
        Me.Dmnhomvattu_IUltraGrid.setChoPhepMenuStrip_In()
        Me.Dmnhomvattu_IUltraGrid.setThemIUltraDropDown(Me.DmtinhtrangIUltraDropDown, Me.ErpharmaDataSet.dmtinhtrang)
        Me.DmtinhtrangIUltraDropDown.setGiaoDien_An_ColumnHeader()
        Me.Cursor = Cursors.Default

    End Sub

    Private Sub btnTaoMoi_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnTaoMoi.Click
        Me.Dmnhomvattu_IUltraGrid.getTaoMoi()

    End Sub

    Private Sub btnLuu_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLuu.Click
        Me.Dmnhomvattu_IUltraGrid.getLuu()

    End Sub

    Private Sub btnXoa_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnXoa.Click
        Me.Dmnhomvattu_IUltraGrid.getXoa()

    End Sub

    Private Sub btnLamTuoi_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLamTuoi.Click
        Me.Dmnhomvattu_IUltraGrid.getRefresh()

    End Sub

    Private Sub btnIn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnIn.Click

        getIn()

    End Sub
    Private Function getThoat() As Boolean
        Try
            Me.Dispose()
            Me.Close()
        Catch ex As Exception
            Return False
        End Try
        Return True
    End Function
    Private Sub btnThoat_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnThoat.Click
        getThoat()

    End Sub
    Private Function getIn() As Boolean
        Try
            Dim rp As DmNhomVatTu_Report = New DmNhomVatTu_Report
            rp.setDt(Me.Dmnhomvattu_IUltraGrid.getDatatableTuIUltraGrid("dmnhomvattu"))
            rp.Show()
            Me.Dmnhomvattu_IUltraGrid.DataSource = Me.ErpharmaDataSet.dmnhomvattu
        Catch ex As Exception
            'Return False
            MsgBox("Xảy ra lỗi :" & ex.Message, MsgBoxStyle.Information, "Thông báo")
        End Try
        Return True
    End Function
End Class